package com.cn.jdbc;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

public interface Base<T> {

	NamedParameterJdbcTemplate getNamedJdbc();


	JdbcTemplate getJdbcTemplate();
	
	/**
	 * 获取表中sql 的 参数字段 如：id,t_name name,t_email email
	 * @return
	 */
	String columnStr();

	int count(String sql);

	/**
	 * 
	 * @param entity
	 * @param sql
	 * @return
	 */
	<T> Long save(T entity, String sql);
	
	/**
	 * 
	 */
	Long save(T entity);

	<T> void saveBatch(String sql, List<T> list) throws Exception;

	void saveBatch(List<T> list) throws Exception;


	void update(T entity) throws Exception;

	<T> void update(String sql, T entity) throws Exception ;
	
	void updateBatch(List<T> list) throws Exception;
	
    /*void delete(T entity) throws Exception;*/

    void delete(Serializable id) throws Exception;
    
    void deleteBatch(List<Integer> list) throws Exception;

    T get(Serializable id) throws Exception;

	<T> T get(String sql, Class<T> mappedClass, Object... param) throws Exception;

	List<T> getList(String sql, Map<String, Object> param) throws Exception;
    
    <T> List<T> getList(String sql, Class<T> mappedClass, Object... param) throws Exception ;
    
    <T> List<T> getList(String sql, Class<T> mappedClass, Map<String, Object> param) throws Exception;

	List<T> getListAll() throws Exception;
	    
}
